home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / ntwrkprt / mstrclnt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  8.6 KB  |  313 lines

  1. /*
  2.  * Copyright (c) 1990, 1991, 1992 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/drapeau/NetworkProtocol/RCS/MAEstroClient.c,v 1.17 92/09/24 14:00:37 drapeau Exp Locker: drapeau $ */
  25. /* $Log:    MAEstroClient.c,v $
  26.  * Revision 1.17  92/09/24  14:00:37  drapeau
  27.  * Modified code to support asynchronous messaging (actually, to be precise,
  28.  * the code now supports one-way RPC's, but conceptually the programmer should
  29.  * think of the messaging as non-blocking).  In Sun RPC, if an RPC call has
  30.  * a timeout value of zero, the sender will not block waiting for a return.
  31.  * To support this model, a new method was added to the Sender object, called
  32.  * "SenderAsynchronousMessaging()".  It will enable or disable synchronous
  33.  * messaging for the sender passed in as argument.  It does this by modifying
  34.  * the Sender's "timeOut" field.  Also, each message in the Sender object
  35.  * modifies a variable global to the NetworkProtocol library; this variable
  36.  * is called "SenderTimeOut" and is used by each message in the Sender class.
  37.  * When a message is sent, the responsible method first sets the SenderTimeOut
  38.  * variable to the timeOut field of the current Sender.
  39.  * Because of these changes, it is no longer necessary to create default
  40.  * timeout values when a New Sender is created (via the NewSender() method).
  41.  * Thus, the code to do so was removed.
  42.  * A final note: the "sender->timeOut" field is new to this version of the code.
  43.  * 
  44.  * Revision 1.16  92/05/29  12:40:32  drapeau
  45.  * Changed the name of the "Selection" structure to "MAESelection",
  46.  * to avoid name conflicts with other software packages and toolkits
  47.  * that might also define a "Selection" structure.
  48.  * 
  49.  * Revision 1.15  91/09/18  12:49:42  drapeau
  50.  * Modified the getportfromname_1() function so that it returns a PortArray* instead of a Port*.
  51.  * Also, changed the name of the major include file from LinkProtocol.h to MAEstro.h, in keeping with
  52.  * the project name.
  53.  * 
  54.  * Revision 1.14  91/09/03  16:55:27  drapeau
  55.  * Modified definition of the "GetPortFromName" message so that it returns
  56.  * a Port* instead of a void*.
  57.  * 
  58.  * Revision 1.13  91/06/19  14:00:01  drapeau
  59.  * Added support for five new messages:
  60.  *  - PauseSelection
  61.  *  - ResumeSelection
  62.  *  - HideApplication
  63.  *  - ShowApplication
  64.  *  - GetAppIcon
  65.  * Also, replaced the "PerformPartialSelection" message with
  66.  * "HaltSelection" message.
  67.  * 
  68.  * Revision 1.12  91/06/17  18:17:16  drapeau
  69.  * Added copyright notice.
  70.  * 
  71.  * Revision 1.11  1991/02/28  07:14:23  drapeau
  72.  * No code changes; this version uses a new version numbering scheme and a new
  73.  * version of RCS.
  74.  *
  75.  * Revision 1.1  90/10/24  18:20:27  drapeau
  76.  * Initial revision
  77.  *  */
  78.  
  79. static char maestroClientRcsid[] = "$Header: /Source/Media/drapeau/NetworkProtocol/RCS/MAEstroClient.c,v 1.17 92/09/24 14:00:37 drapeau Exp Locker: drapeau $";
  80.  
  81. #include <rpc/rpc.h>
  82. #include <sys/time.h>
  83. #include <MAEstro.h>
  84.  
  85. static struct timeval    myTIMEOUT = { 5, 0 };
  86. struct timeval*        SenderTimeOut = &myTIMEOUT;
  87.  
  88. void* opendocument_1(char** argp, CLIENT* clnt)
  89. {
  90.   static char res;
  91.   
  92.   bzero((char *)&res, sizeof(res));
  93.   if (clnt_call(clnt, OpenDocumentProc, xdr_wrapstring,
  94.         (caddr_t)argp, xdr_void, &res, SenderTimeOut) != RPC_SUCCESS)
  95.     {
  96.       return (NULL);
  97.     }
  98.   return ((void *)&res);
  99. }
  100.  
  101.  
  102. char** getcurrentdocname_1(void* argp, CLIENT* clnt)
  103. {
  104.   static char* res;
  105.   
  106.   bzero((char *)&res, sizeof(res));
  107.   if (clnt_call(clnt, GetCurrentDocNameProc, xdr_void,
  108.         (caddr_t)argp, xdr_wrapstring, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  109.     {
  110.       return (NULL);
  111.     }
  112.   return (&res);
  113. }
  114.  
  115.  
  116. MAESelection* getselection_1(void* argp, CLIENT* clnt)
  117. {
  118.   static MAESelection res;
  119.   
  120.   bzero((char *)&res, sizeof(res));
  121.   if (clnt_call(clnt, GetSelectionProc, xdr_void,
  122.         (caddr_t)argp, xdr_MAESelection, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  123.     {
  124.       return (NULL);
  125.     }
  126.   return (&res);
  127. }
  128.  
  129.  
  130. void* setselection_1(MAESelection* argp, CLIENT* clnt)
  131. {
  132.   static char res;
  133.   
  134.   bzero((char *)&res, sizeof(res));
  135.   if (clnt_call(clnt, SetSelectionProc, xdr_MAESelection,
  136.         (caddr_t)argp, xdr_void, &res, SenderTimeOut) != RPC_SUCCESS)
  137.     {
  138.       return (NULL);
  139.     }
  140.   return ((void *)&res);
  141. }
  142.  
  143.  
  144. void* performselection_1(void* argp, CLIENT* clnt)
  145. {
  146.   static char res;
  147.   
  148.   bzero((char *)&res, sizeof(res));
  149.   if (clnt_call(clnt, PerformSelectionProc, xdr_void,
  150.         (caddr_t)argp, xdr_void, &res, SenderTimeOut) != RPC_SUCCESS)
  151.     {
  152.       return (NULL);
  153.     }
  154.   return ((void *)&res);
  155. }
  156.  
  157.  
  158. void* connectwithportmgr_1(Port* argp, CLIENT* clnt)
  159. {
  160.   static char res;
  161.   
  162.   bzero((char *)&res, sizeof(res));
  163.   if (clnt_call(clnt, ConnectWithPortMgrProc, xdr_Port,
  164.         (caddr_t)argp, xdr_void, &res, SenderTimeOut) != RPC_SUCCESS)
  165.     {
  166.       return ((void*)NULL);
  167.     }
  168.   return ((void *)&res);
  169. }
  170.  
  171.  
  172.  
  173. PortArray* getopenapps_1(void* argp, CLIENT* clnt)
  174. {
  175.   static PortArray res;
  176.   
  177.   bzero((char *)&res, sizeof(res));
  178.   if (clnt_call(clnt, GetOpenAppsProc, xdr_void,
  179.         (caddr_t)argp, xdr_PortArray, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  180.     {
  181.       return (NULL);
  182.     }
  183.   return ((PortArray*)&res);
  184. }
  185.  
  186.  
  187. PortArray* getportfromname_1(Port* argp, CLIENT* clnt)
  188. {
  189.   static PortArray res;
  190.   
  191.   bzero((char *)&res, sizeof(res));
  192.   if (clnt_call(clnt, GetPortFromNameProc, xdr_Port,
  193.         (caddr_t)argp, xdr_PortArray, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  194.     {
  195.       return ((PortArray*) NULL);
  196.     }
  197.   return ((PortArray*)&res);
  198. }
  199.  
  200.  
  201. void* disconnectfromportmgr_1(Port* argp, CLIENT* clnt)
  202. {
  203.   static char res;
  204.   
  205.   bzero((char *)&res, sizeof(res));
  206.   if (clnt_call(clnt, DisconnectFromPortMgrProc, xdr_Port,
  207.         (caddr_t)argp, xdr_void, &res, SenderTimeOut) != RPC_SUCCESS)
  208.     {
  209.       return (NULL);
  210.     }
  211.   return ((void *)&res);
  212. }
  213.  
  214.  
  215. void* ping_1(void* argp, CLIENT* clnt)
  216. {
  217.   static char res;
  218.   
  219.   bzero((char *)&res, sizeof(res));
  220.   if (clnt_call(clnt, PingProc, xdr_void,
  221.         (caddr_t)argp, xdr_void, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  222.     {
  223.       return (NULL);
  224.     }
  225.   return ((void *)&res);
  226. }
  227.  
  228.  
  229. void* haltselection_1(void* argp, CLIENT* clnt)
  230. {
  231.   static char res;
  232.   
  233.   bzero((char *)&res, sizeof(res));
  234.   if (clnt_call(clnt, HaltSelectionProc, xdr_void,
  235.         (caddr_t)argp, xdr_void, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  236.   {
  237.     return (NULL);
  238.   }
  239.   return ((void *)&res);
  240. }
  241.  
  242.  
  243. void*    pauseselection_1(void *argp, CLIENT *clnt)
  244. {
  245.   static char res;
  246.   
  247.   bzero((char *)&res, sizeof(res));
  248.   if (clnt_call(clnt, PauseSelectionProc, xdr_void,
  249.         (caddr_t)argp, xdr_void, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  250.   {
  251.     return (NULL);
  252.   }
  253.   return ((void *)&res);
  254. }
  255.  
  256.  
  257. void*    resumeselection_1(void *argp, CLIENT *clnt)
  258. {
  259.   static char res;
  260.   
  261.   bzero((char *)&res, sizeof(res));
  262.   if (clnt_call(clnt, ResumeSelectionProc, xdr_void,
  263.         (caddr_t)argp, xdr_void, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  264.   {
  265.     return (NULL);
  266.   }
  267.   return ((void *)&res);
  268. }
  269.  
  270.  
  271. void*    hideapplication_1(void *argp, CLIENT *clnt)
  272. {
  273.   static char res;
  274.   
  275.   bzero((char *)&res, sizeof(res));
  276.   if (clnt_call(clnt, HideApplicationProc, xdr_void,
  277.         (caddr_t)argp, xdr_void, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  278.   {
  279.     return (NULL);
  280.   }
  281.   return ((void *)&res);
  282. }
  283.  
  284.  
  285.  
  286. void*    showapplication_1(void *argp, CLIENT *clnt)
  287. {
  288.   static char res;
  289.   
  290.   bzero((char *)&res, sizeof(res));
  291.   if (clnt_call(clnt, ShowApplicationProc, xdr_void,
  292.         (caddr_t)argp, xdr_void, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  293.   {
  294.     return (NULL);
  295.   }
  296.   return ((void *)&res);
  297. }
  298.  
  299.  
  300.  
  301. IconData*    getappicon_1(void *argp, CLIENT *clnt)
  302. {
  303.   static IconData res;
  304.   
  305.   bzero((char *)&res, sizeof(res));
  306.   if (clnt_call(clnt, GetAppIconProc, xdr_void,
  307.         (caddr_t)argp, xdr_IconData, (caddr_t)&res, SenderTimeOut) != RPC_SUCCESS)
  308.   {
  309.     return (NULL);
  310.   }
  311.   return (&res);
  312. }
  313.